//
//  YoutubePlayerViewController.swift
//  DownloadTube
//
//  Created by Carlos on 15/10/14.
//  Copyright (c) 2014 Carlos. All rights reserved.
//

import UIKit

class YoutubePlayerViewController: UIViewController, YTPlayerViewDelegate {

    var playerVars:NSDictionary = ["autoplay" : 1, "eurl" : "https://www.youtube.com"];
    var videoId:String = "Da87BbEfUOY"

    @IBOutlet weak var player: YTPlayerView!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        player.loadWithVideoId(videoId)
        player.delegate=self
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
     func playerViewDidBecomeReady( playerView: YTPlayerView){
        player.playVideo()
    }
    
    func didChangeToState (playerView: YTPlayerView, state:YTPlayerState){
        
    }
    
    func playerView(playerView: UITableView, didChangeToState state: YTPlayerState){
        println(state.value)
    }
 }
